# Importing Data
TURKEY <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "AJ1:AJ239")

# Checking the Imported Data
View(TURKEY)
# Creating Time Series Data
TURKEY_ts <- ts(TURKEY, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
TURKEY_ts
sum(is.na(TURKEY_ts))
library(forecast)
TURKEY_ts <- tsclean(TURKEY_ts)
TURKEY_ts

# Identification: Plotting the Time Series Data
plot(TURKEY_ts)

# Estimating the appropriate model
TURKEY_ts_model <- auto.arima(TURKEY_ts)
TURKEY_ts_model

# Forecasting
options(max.print=1000000)
TURKEY_ts_forecast <- forecast (TURKEY_ts_model, level=c(95), h=255)
plot(TURKEY_ts_forecast)
TURKEY_ts_forecast             

# Exporting
write.table(TURKEY_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/TURKEY_TSA.csv", sep=",")
